package com.seata.logic.visualize.tcc;

import com.seata.logic.visualize.dto.OrderCreateDto;
import io.seata.rm.tcc.api.BusinessActionContext;
import io.seata.rm.tcc.api.BusinessActionContextParameter;
import io.seata.rm.tcc.api.LocalTCC;
import io.seata.rm.tcc.api.TwoPhaseBusinessAction;

/**
 * @author 蚂蚁会花呗
 * @date 2021/9/26 16:09
 */
@LocalTCC
public interface OrderTccAction {

    /**
     * 一阶段的try阶段
     * commitMethod要对应二阶段提交的方法名
     * rollbackMethod要对应二阶段回滚的方法名
     * @return
     */
    @TwoPhaseBusinessAction(name = "orderAction",commitMethod = "commit",rollbackMethod = "rollback")
    boolean createOrder(BusinessActionContext businessActionContext, @BusinessActionContextParameter(paramName = "order") OrderCreateDto orderCreateDto);


    /***
     * 二阶段提交
     * @param businessActionContext
     * @return
     */
    boolean commit(BusinessActionContext businessActionContext);

    /**
     * 二阶段回滚
     * @param businessActionContext
     * @return
     */
    boolean rollback(BusinessActionContext businessActionContext);

}
